<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>植百汇入库单</title>
    <script type="text/javascript" src="${ctxStatic}/plugin/layui2.0/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="${ctxStatic}/plugin/layui2.0/layui.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/plugin/layui2.0/css/layui.css" media="all">
    <script>
        var ctx = '${ctx}';
        var evidenceId  = '${wr.evidenceId}';
    </script>
     <%@ include file="/webpage/include/bootstraptable.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/common/css/app-blue.css" media="all"> 
    <link rel="stylesheet" href="${ctxStatic}/purchase/add_purchase.css" media="all"> 
        <script>
    	//查找仓库类型-原
        function findWarehouseType(warehouseType,arr){
            $.ajax({
                type : "post",
                url : ctx+"/sys/dict/findWarehouseTypeByTypeList?typeList="+arr, //此次url改为真正需要的url
                success : function(data) {
                    var optionstring = "<option value=''>"+"直接选择或搜索选择"+"</option>";
                    if(data!=null){
                        for(var i=0;i<data.length;i++){
                            optionstring += "<option value=\"" + data[i].value+ "\">" +data[i].label+ "</option>";
                        }
                    }
                    $("#"+warehouseType).html(optionstring);
                    layui.use('form', function () {
                        var form = layui.form;
                        form.render();
                    });
                }
            });
        }

        function findWarehouse(warehouseId,warehouseType) {
            $("#"+warehouseId).empty();
            var type=$("#"+warehouseType).val();
            $.ajax({
                type : "post",
                url : ctx+"/warehouse/warehouse/findByType?warehouseType="+type, //此次url改为真正需要的url
                success : function(data) {
                    var optionstring = "";
                    if(data!=null){
                        for(var i=0;i<data.length;i++){
                            optionstring += "<option value=\"" + data[i].id+ "\">" +data[i].warehouseName+ "</option>";
                        }
                    }
                    $("#"+warehouseId).html(optionstring);
                    layui.use('form', function () {
                        var form = layui.form;
                        form.render();
                    });
                }
            });
        };
    </script>
</head>
<body style="width:100%; height:100%; overflow: scroll; -webkit-overflow-scrolling: touch;">
	<div class="wrapper wrapper-content">				
			<div class="row">
				<div class="col-md-12">
					<div class="panel panel-primary">
						<div class="panel-heading">
							<h3 class="panel-title"> 
							    <span style="font-size:12px">入库单查看  </span> 
								<a class="panelButton" href="${ctx}/warehouse/warehouseReceipt"><i class="ti-angle-left"></i> 返回</a>
							</h3>
						</div>
						<div class="panel-body">
						    <form class="layui-form" action="">
						        <!--入库单信息start-->
						        <div class="row">
						            <div class="col-xs-12 col-sm-6 col-md-3">
						                <label class="label-txt col-xs-4 col-sm-3" >仓库：</label>
						                <div class="layui-input-inline col-xs-8 col-sm-9">
						                  <select model="select"  id="warehouse" name="warehouse" lay-verify="required" lay-search="">
						                       <option value="1">${wr.warehouseName}</option>
						                    </select>
						                </div>
						            </div>
						        </div>
						        <!--入库单信息end-->
						    
						        <div class="row remarkRow">
							        <div class="col-xs-12 col-sm-9 col-md-9 ">
							        	 <label class='label-txt col-xs-4 col-sm-3 '>备注:</label>
							            <div class="layui-input-inline col-xs-8 col-sm-11">
							                <textarea readOnly class="layui-textarea">${wr.remarks}</textarea>
							            </div>
							        </div>
						        </div>
						         <!-- 工具栏 -->
						         <div id="toolbar">
				                        <span  class="btn btn-danger" onclick="reBack()">
				                            <i class="glyphicon glyphicon-save"></i>关闭
				                        </span>
				                </div>
				                <!-- 工具栏 -->
						        <style>
						                #purchaseOrder .self-adaption-wrap {
						                   overflow-x: scroll;
						               }
						               .self-adaption-wrap::-webkit-scrollbar {
						                   display: none;
						               }
						               #purchaseOrder .self-adaption-input{
						                   min-width: 200px;
						               }
						        </style>
						        <!--动态添加数据start-->
						        <div>
						        	<table id="purchaseOrder" data-toolbar="#toolbar"></table>
						        </div>
						        	
						        <!--动态添加数据end-->
						        <hr/>
						    </form>
						</div>
					</div>
				</div>
			</div>
		</div>
 </body>
 <script>
    findWarehouseType("warehouseType",['1']);
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        form.on('select(warehouseType)', function(data){
            findWarehouse('warehouse','warehouseType');
            form.render();
        });
    });
</script>
<script>
    function reBack(){
		window.location.href = "${ctx}/warehouse/warehouseReceipt";
	}
    function initData(){
        //加载sku数据
        $('#purchaseOrder').bootstrapTable({
           url: "${ctx}/warehouse/warehouseReceipt/findPurchaseOrderActualItem?evidenceId="+evidenceId,//此接口需要修改！！！
     	   contentType : "application/x-www-form-urlencoded",   //必须有
           striped: true,
      	   columns: [
      		   {
      	           title: '序号',
      	           field:'scount',
      	           formatter: function (value, row, index) {
      	               return index + 1;
      	           },
      	       },
      		   {
      			   title:'SKUID',
      			   field:'skuId'
      		   },
      		   {
      		       field:'skuName',
    	           title: 'SKU',
    	       },
    	       {
    	           field: 'amount',
    	           title: '采购数量'
    	        }, 
    	        {
    	           field: 'price',
    	           title: '采购单价'
    	        }
    	   ]
        });
    }
    $(function(){
    	initData();
    	if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
	   		 $('#purchaseOrder').bootstrapTable("toggleView");
	   	}
    });
</script>
</html>